package top.jsjkxyjs.blackbox.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import top.jsjkxyjs.blackbox.entity.Car;
import top.jsjkxyjs.blackbox.entity.Cartype;
import top.jsjkxyjs.blackbox.mapper.CarMapper;
import top.jsjkxyjs.blackbox.mapper.CarTypeMapper;
import top.jsjkxyjs.blackbox.service.CarTypeService;

import java.util.List;

@Service
public class CarTypeServiceImpl implements CarTypeService {
	@Autowired
	CarTypeMapper carTypeMapper;
	@Autowired
	CarMapper carMapper;

	@Override
	public List<Cartype> getAllCarType() {
		List<Cartype> cartypes = carTypeMapper.selectList(null);
		return cartypes;
	}

	@Override
	public String getCarTypeByCarId(int carId) {
		//TODO
		Car car = carMapper.selectById(carId);
		Cartype cartype = carTypeMapper.selectById(car.getType());
		return cartype.getName();
	}
}
